/**
 * 功能描述
 */
define(function (require, exports, module) {
	var Grid = new require("grid");
	var aw = new require("ajaxwrapper");
	var Dialog = require("dialog");
	var store = require("store");
	var activeUser = store.get("user");
	var procAllianceOrg = require("../store/procAllianceOrg");
    var instance = {
        initComponent: function (params,widget) {
        	var grid = new Grid({
        		parentNode:".J-grid",
        		url:"api/allianceorg/query",
        		params :function(){
        			var obj={
        					fetchProperties:procAllianceOrg.fetchProperties
        			}
        			return obj;
        		},
        		model:{
        			columns:[{
        				name:"name",
        				label:"名称",
        			},{
        				name:"orgOwnership.value",
        				label:"企业性质",
        			},{
        				name:"address",
        				label:"地址",
        				format : function(value,row){
        					return row.address.fullName + '' + row.street; 
        				}
        			},{
        				name : "principal",
                        label : "负责人"
        			},{
        				 name : "phone",
                         label : "联系电话"
        			},{
        				name:"show",
        				label:"操作",
        				format:"button",
        				formatparams:[{
        					id:"edit",
        					icon:"icon-edit",
        					handler:function(index,data,rowEle){
        						widget.get("subnav").hide(["add"]).show(["return"]);
        						widget.hide([".J-grid"]).show([".J-form"]);
        						widget.get("form").reset();
        						widget.get("form").setData(data);
        						widget.get("form").setValue("organization", data.organization.pkOrganization);
        					}
        				},{
        					id:"delete",
        					icon:"icon-remove",
        					handler:function(index,data,rowEle){
        						aw.del("api/allianceorg/"+data.pkAllianceOrg+"/delete",function() {
									grid.refresh();
								});	
        					}
        				}]
        			}]
        		}
        	});
        	widget.set("grid",grid);
        }
    };
    module.exports = instance;
});
